<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.io.*,java.util.*"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>

<meta charset="UTF-8">
<title>订单</title>
<link href="../css/merchant.css" rel="stylesheet" type="text/css" />
<script language="JavaScript"
	src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script language="JavaScript" src="../js/bootstrap.js"></script>  
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />
<link rel="icon" href="../img/index.ico">
<link rel="stylesheet" type="text/css" href="../css/normalize.css" />
<link rel="stylesheet" type="text/css" href="../css/demo.css" />
<link rel="stylesheet" type="text/css" href="../css/icons.css" />
<link rel="stylesheet" type="text/css" href="../css/component.css" />
<link rel="stylesheet" type="text/css" href="../css/head.css" />
<link rel="stylesheet" type="text/css" href="../css/order_manager.css" />
<script type="text/javascript">
$(document).ready(function(){
	$("body").on("mouseenter","tr",function(){
		$(this).css("background-color","#efe2d2");
	}); 
	
	
	$("body").on("mouseleave","tr",function(){
		$(this).css("background-color","");
	}); 
	
});
</script>
</head>
<body>

	<ul id="nav" class="hul">
	<img src="http://10.222.232.168:83/img/logo.png"/>
	<li class="logout"><a href="logOut" >注销</a></li>
	<li class="logout"><a href="orderManager.jsp" id="newMsg"></p></a></li>
	</ul>

	<div id="st-container" class="st-container">
		<!--
        example menus
        these menus will be on top of the push wrapper
    -->
		<nav class="st-menu st-effect-1" id="menu-1">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-2" id="menu-2">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-4" id="menu-4">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-5" id="menu-5">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-9" id="menu-9">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-10" id="menu-10">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-11" id="menu-11">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-12" id="menu-12">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>

		<nav class="st-menu st-effect-13" id="menu-13">
			<h2 class="icon icon-lab">商家</h2>
			<ul>
				<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
				<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
				<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
				<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
			</ul>
		</nav>


		<div class="st-pusher">
			<nav class="st-menu st-effect-3" id="menu-3">
				<h2 class="icon icon-lab">商家</h2>
				<ul>
					<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
					<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
					<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
					<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
				</ul>
			</nav>

			<nav class="st-menu st-effect-6" id="menu-6">
				<h2 class="icon icon-lab">商家</h2>
				<ul>
					<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
					<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
					<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
					<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
				</ul>
			</nav>

			<nav class="st-menu st-effect-7" id="menu-7">
				<h2 class="icon icon-lab">商家</h2>
				<ul>
					<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
					<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
					<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
					<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
				</ul>
			</nav>

			<nav class="st-menu st-effect-8" id="menu-8">
				<h2 class="icon icon-lab">商家</h2>
				<ul>
					<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
					<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
					<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
					<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
				</ul>
			</nav>

			<nav class="st-menu st-effect-14" id="menu-14">
				<h2 class="icon icon-lab">商家</h2>
				<ul>
					<li><a class="icon icon-data" href="dishManager.jsp">菜单管理</a></li>
					<li><a class="icon icon-study" href="orderManager.jsp">订单管理</a></li>
					<li><a class="icon icon-wallet" href="historyOrder.jsp">历史订单</a></li>
					<li><a class="icon icon-phone" href="findMerchant">商家信息</a></li>
				</ul>
			</nav>
			<div class="st-content">
				<div class="st-content-inner">

					<div class="main clearfix">
						<div id="st-trigger-effects" class="column">

							<button data-effect="st-effect-8">商家管理</button>

						</div>
						<div class="dish">

							<div id="nottaken" class="location"></div>
							<div  id="taken" class="location1"></div>
							<div  id="doNotTake" class="location2"></div>
					</div>
				</div>
			</div>
			</div>
			</div>
			<script src="../js/classie.js"></script>
			<script src="../js/sidebarEffects.js"></script>
</body>
</html>



</body>
<script type="text/javascript">
	$(document).ready(function() { 

		var ws = new WebSocket('ws://10.222.232.168:8099/Merchant/websocket');
		
        ws.onopen = function () {
         console.log("onopen")
        };

        ws.onmessage = function (event) {
            console.log("onmessage");
            var newMsgText=document.getElementById("newMsg");
            newMsgText.innerHTML="您有新订单";
        };

        ws.onclose = function (event) {
            console.log("onclose")
        };
		
		loadAllData();
	});

	function loadAllData() {
		$.ajax("loadNotTakenOrder", {
			method : "GET",
			type : "json",
			success : function(result) {
				
				if (result) {
					if(typeof (result)=="string"){
						if (result.indexOf("<title>登录</title>")) {
							location.href= "merchantLogin.jsp";
						} 
					}
			 
				
					parserData(result);
				}
				;
			}
		});
	}
	function parserData(result) {
		if (result.doNotTake) {
			parseDoNotTake(result.doNotTake);
		}
		;
		if (result.notTaken) {
			parseNotTaken(result.notTaken);
		}
		;
		if (result.taken) {
			parseTaken(result.taken);
		}
		;
	}

	function parseNotTaken(data) {
		var notTake = document.getElementById("nottaken"); 
		
		var tb = document.createElement("table"); 
		tb.setAttribute("class","table table-hover table1"); 
		tb.setAttribute("id", "notTakenTable")
		tb.setAttribute("width","100%");
		data.forEach(function(item, index, array) {
			var thead=document.createElement("thead");
			thead.setAttribute("id",item.oid);
			var tfoot=document.createElement("tfoot");
			var tbody=document.createElement("tbody");
			var dishes = JSON.parse(item.dishs); 

			
			var tr1 = document.createElement("tr");
			var th1 = document.createElement("th");

			th1.innerHTML = "下单时间："+item.orderTime;
			th1.setAttribute("colspan","2");
			var th2 = document.createElement("th");
			th2.innerHTML = "购买者："+item.user.account;
			var th3 = document.createElement("th");
			if (item.taken == 1) {
				th3.innerHTML = "状态：已接单";
			}
			if(item.taken==0){
				th3.innerHTML="状态：未接单";
			}
			if (item.taken == -2) {
				th3.innerHTML = "状态：不接单";
			}
			if (item.taken == -1) {
				th3.innerHTML = "状态：已收货";
			}
			var th4 = document.createElement("th");
			th4.innerHTML = "总价：￥"+item.total;
			tr1.appendChild(th1);
			tr1.appendChild(th2);
			tr1.appendChild(th3);
			tr1.appendChild(th4);
			thead.appendChild(tr1);

			for (var j = 0; j < dishes.length; j++) {
				var tr2 = document.createElement("tr");
				var dtd1 = document.createElement("td");
				var dtd2 = document.createElement("td");
				var dtd3 = document.createElement("td");
				var dtd4 = document.createElement("td");
				var dtd5 = document.createElement("td");
				var img = document.createElement("img");
				img.setAttribute("src", dishes[j].dicon);
				img.setAttribute("width", "50");
				img.setAttribute("height", "50");
				dtd1.appendChild(img);

				dtd2.innerHTML = dishes[j].dname;
				dtd3.innerHTML = '￥'+ dishes[j].price;
				
				dtd4.innerHTML = dishes[j].num;
				dtd5.innerHTML='￥'+dishes[j].num*dishes[j].price;
				tr2.appendChild(dtd1);
				tr2.appendChild(dtd2);
				tr2.appendChild(dtd3);
				tr2.appendChild(dtd4);
				tr2.appendChild(dtd5);
				tbody.appendChild(tr2);
			}
			
			var tr3 = document.createElement("tr");
			var ftd1= document.createElement("td"); 
			var ftd2= document.createElement("td");
			ftd1.setAttribute("colspan","4");
			var but1 = document.createElement("button");
			var but2 = document.createElement("button");
			but1.innerHTML = "接单";
			but2.innerHTML = "不接单";
			but1.onclick = function() { 
				accept(item.oid)
			};
			but2.onclick = function() {
				refuse(item.oid)
			};
			ftd2.appendChild(but1);
			ftd2.appendChild(but2);
			tr3.appendChild(ftd1);
			tr3.appendChild(ftd2);
			tbody.appendChild(tr3);
			
			tb.appendChild(thead);
			tb.appendChild(tbody);
			tb.appendChild(tfoot);
			
		});
		notTake.appendChild(tb);
	}

	function parseTaken(data) {
		var notTake = document.getElementById("taken");
			
		var tb = document.createElement("table"); 
		tb.setAttribute("class","table table-hover table2");  
	  	tb.setAttribute("id","takenTable");
		data.forEach(function(item, index, array) { 
			var thead=document.createElement("thead");
			
			var tfoot=document.createElement("tfoot");
			var tbody=document.createElement("tbody");
			var dishes = JSON.parse(item.dishs); 

			
			var tr1 = document.createElement("tr");
			var th1 = document.createElement("th");
			th1.innerHTML = "下单时间："+item.orderTime;
			th1.setAttribute("colspan","2");
			var th2 = document.createElement("th");
			th2.innerHTML = "购买者："+item.user.account;
			var th3 = document.createElement("th");
			if (item.taken == 1) {
				th3.innerHTML = "状态：已接单";
			}
			if(item.taken==0){
				th3.innerHTML="状态：未接单";
			}
			if (item.taken == -2) {
				th3.innerHTML = "状态：不接单";
			}
			if (item.taken == -1) {
				th3.innerHTML = "状态：已收货";
			}
			var th4 = document.createElement("th");
			th4.innerHTML = "总价：￥"+item.total;
			tr1.appendChild(th1);
			tr1.appendChild(th2);
			tr1.appendChild(th3);
			tr1.appendChild(th4);
			thead.appendChild(tr1);

			for (var j = 0; j < dishes.length; j++) {
				var tr2 = document.createElement("tr");
				var dtd1 = document.createElement("td");
				var dtd2 = document.createElement("td");
				var dtd3 = document.createElement("td");
				var dtd4 = document.createElement("td");
				var dtd5 = document.createElement("td");
				var img = document.createElement("img");
				img.setAttribute("src", dishes[j].dicon);
				img.setAttribute("width", "50");
				img.setAttribute("height", "50");
				dtd1.appendChild(img);

				dtd2.innerHTML = dishes[j].dname;
				dtd3.innerHTML = '￥'+ dishes[j].price;
				
				dtd4.innerHTML = dishes[j].num;
				dtd5.innerHTML='￥'+dishes[j].num*dishes[j].price;
				tr2.appendChild(dtd1);
				tr2.appendChild(dtd2);
				tr2.appendChild(dtd3);
				tr2.appendChild(dtd4);
				tr2.appendChild(dtd5);
				tbody.appendChild(tr2);
			}
			if(item.comments){
			var tr3 = document.createElement("tr");
			var ftd1= document.createElement("td"); 
			var ftd2= document.createElement("td");
			ftd1.setAttribute("colspan","4"); 
			var but=document.createElement("button");
			but.innerHTML="投诉进度";
			ftd2.appendChild(but);
			tr3.appendChild(ftd1);
			tr3.appendChild(ftd2);
			tbody.appendChild(tr3);}
			
			tb.appendChild(thead);
			tb.appendChild(tbody);
			tb.appendChild(tfoot);
			
		});
		notTake.appendChild(tb);
	}
	function parseDoNotTake(data) {
		var notTake = document.getElementById("doNotTake");
        
		var tb = document.createElement("table"); 
		tb.setAttribute("class","table table-hover table3"); 
	  	tb.setAttribute("id","doNotTakeTable");
		data.forEach(function(item, index, array) {
			var thead=document.createElement("thead");
			var tfoot=document.createElement("tfoot");
			var tbody=document.createElement("tbody");
			var dishes = JSON.parse(item.dishs); 

			
			var tr1 = document.createElement("tr"); 
			var th1 = document.createElement("th");

			th1.innerHTML = "下单时间："+item.orderTime;
			th1.setAttribute("colspan","2");
			var th2 = document.createElement("th");
			th2.innerHTML = "购买者："+item.user.account;
			var th3 = document.createElement("th");
			if (item.taken == 1) {
				th3.innerHTML = "状态：已接单";
			}
			;
			if (item.taken == -2) {
				th3.innerHTML = "状态：不接单";
			}
			if (item.taken == -1) {
				th3.innerHTML = "状态：已收货";
			}
			var th4 = document.createElement("th");
			th4.innerHTML = "总价：￥"+item.total;
			tr1.appendChild(th1);
			tr1.appendChild(th2);
			tr1.appendChild(th3);
			tr1.appendChild(th4);
			thead.appendChild(tr1);

			for (var j = 0; j < dishes.length; j++) {
				var tr2 = document.createElement("tr");
				var dtd1 = document.createElement("td");
				var dtd2 = document.createElement("td");
				var dtd3 = document.createElement("td");
				var dtd4 = document.createElement("td");
				var dtd5 = document.createElement("td");
				var img = document.createElement("img");
				img.setAttribute("src", dishes[j].dicon);
				img.setAttribute("width", "50");
				img.setAttribute("height", "50");
				dtd1.appendChild(img);

				dtd2.innerHTML = dishes[j].dname;
				dtd3.innerHTML = '￥'+ dishes[j].price;
				
				dtd4.innerHTML = dishes[j].num;
				dtd5.innerHTML='￥'+dishes[j].num*dishes[j].price;
				tr2.appendChild(dtd1);
				tr2.appendChild(dtd2);
				tr2.appendChild(dtd3);
				tr2.appendChild(dtd4);
				tr2.appendChild(dtd5);
				tbody.appendChild(tr2);
			}
			if(item.comments){
			var tr3 = document.createElement("tr");
			var ftd1= document.createElement("td"); 
			var ftd2= document.createElement("td");
			ftd1.setAttribute("colspan","4");
			
				ftd1.innerHTML=item.comments;
			
			var but=document.createElement("button");
			but.innerHTML="投诉进度";
			ftd2.appendChild(but);
			tr3.appendChild(ftd1);
			tr3.appendChild(ftd2);
			tbody.appendChild(tr3);}
			
			tb.appendChild(thead);
			tb.appendChild(tbody);
			tb.appendChild(tfoot);
			
		});
		notTake.appendChild(tb);
	}

	function accept(param) {
		console.log("accept");
		thead = document.getElementById(param);
		var rootdiv = document.getElementById("notTakenTable");
		tbody=thead.nextSibling;
		rootdiv.removeChild(thead);
		tbody.parentNode.removeChild(tbody);
		oId = param;
		var data = {
			"oId" : oId
		}
		$.ajax("takeOrder/"+oId, {
			method : "GET",
			type : "json",
			//data : data,
			success : function(item) {
				var tb = document.getElementById("takenTable");
				// var obj = JSON.parse(result);
				var thead=document.createElement("thead");
			var tfoot=document.createElement("tfoot");
			var tbody=document.createElement("tbody");
			var dishes = JSON.parse(item.dishs); 
             
			var tr1 = document.createElement("tr");
			var th1 = document.createElement("th");

			th1.innerHTML = "下单时间："+item.orderTime;
			th1.setAttribute("colspan","2");
			var th2 = document.createElement("th");
			th2.innerHTML = "购买者："+item.user.account;
			var th3 = document.createElement("th");
			if (item.taken == 1) {
				th3.innerHTML = "状态：已接单";
			}
			;
			if (item.taken == -2) {
				th3.innerHTML = "状态：不接单";
			}
			if (item.taken == -1) {
				th3.innerHTML = "状态：已收货";
			}
			var th4 = document.createElement("th");
			th4.innerHTML = "总价：￥"+item.total;
			tr1.appendChild(th1);
			tr1.appendChild(th2);
			tr1.appendChild(th3);
			tr1.appendChild(th4);
			thead.appendChild(tr1);

			for (var j = 0; j < dishes.length; j++) {
				var tr2 = document.createElement("tr");
				var dtd1 = document.createElement("td");
				var dtd2 = document.createElement("td");
				var dtd3 = document.createElement("td");
				var dtd4 = document.createElement("td");
				var dtd5 = document.createElement("td");
				var img = document.createElement("img");
				img.setAttribute("src", dishes[j].dicon);
				img.setAttribute("width", "50");
				img.setAttribute("height", "50");
				dtd1.appendChild(img);

				dtd2.innerHTML = dishes[j].dname;
				dtd3.innerHTML = '￥'+ dishes[j].price;
				
				dtd4.innerHTML = dishes[j].num;
				dtd5.innerHTML='￥'+dishes[j].num*dishes[j].price;
				tr2.appendChild(dtd1);
				tr2.appendChild(dtd2);
				tr2.appendChild(dtd3);
				tr2.appendChild(dtd4);
				tr2.appendChild(dtd5);
				tbody.appendChild(tr2);
			}
			if(item.comments){
			var tr3 = document.createElement("tr");
			var ftd1= document.createElement("td"); 
			var ftd2= document.createElement("td");
			ftd1.setAttribute("colspan","4");
			
				ftd1.innerHTML=item.comments;
			
			var but=document.createElement("button");
			but.innerHTML="投诉进度";
			ftd2.appendChild(but);
			tr3.appendChild(ftd1);
			tr3.appendChild(ftd2);
			tbody.appendChild(tr3);}
			
			tb.appendChild(thead);
			tb.appendChild(tbody);
			}
		});
	};
	function refuse(param) {
		console.log("refuse"); 
		thead = document.getElementById(param);
		var rootdiv = document.getElementById("notTakenTable");
		tbody=thead.nextSibling;
		rootdiv.removeChild(thead);
		tbody.parentNode.removeChild(tbody);
		oId = param;
		var data = {
			"oId" : oId
		}
		$.ajax("refuseOrder", {
			method : "GET",
			type : "json",
			data : data,
			success : function(item) {
				var tb = document.getElementById("doNotTakeTable");
				// var obj = JSON.parse(result);
				var thead=document.createElement("thead");
			var tfoot=document.createElement("tfoot");
			var tbody=document.createElement("tbody");
			var dishes = JSON.parse(item.dishs); 

			
			var tr1 = document.createElement("tr");
			var th1 = document.createElement("th");

			th1.innerHTML = "下单时间："+item.orderTime;
			th1.setAttribute("colspan","2");
			var th2 = document.createElement("th");
			th2.innerHTML = "购买者："+item.user.account;
			var th3 = document.createElement("th");
			if (item.taken == 1) {
				th3.innerHTML = "状态：已接单";
			}
			;
			if (item.taken == -2) {
				th3.innerHTML = "状态：不接单";
			}
			if (item.taken == -1) {
				th3.innerHTML = "状态：已收货";
			}
			var th4 = document.createElement("th");
			th4.innerHTML = "总价：￥"+item.total;
			tr1.appendChild(th1);
			tr1.appendChild(th2);
			tr1.appendChild(th3);
			tr1.appendChild(th4);
			thead.appendChild(tr1);

			for (var j = 0; j < dishes.length; j++) {
				var tr2 = document.createElement("tr");
				var dtd1 = document.createElement("td");
				var dtd2 = document.createElement("td");
				var dtd3 = document.createElement("td");
				var dtd4 = document.createElement("td");
				var dtd5 = document.createElement("td");
				var img = document.createElement("img");
				img.setAttribute("src", dishes[j].dicon);
				img.setAttribute("width", "50");
				img.setAttribute("height", "50");
				dtd1.appendChild(img);

				dtd2.innerHTML = dishes[j].dname;
				dtd3.innerHTML ='￥'+  dishes[j].price;
				
				dtd4.innerHTML = dishes[j].num;
				dtd5.innerHTML='￥'+dishes[j].num*dishes[j].price;
				tr2.appendChild(dtd1);
				tr2.appendChild(dtd2);
				tr2.appendChild(dtd3);
				tr2.appendChild(dtd4);
				tr2.appendChild(dtd5);
				tbody.appendChild(tr2);
			}
			if(item.comments){
			var tr3 = document.createElement("tr");
			var ftd1= document.createElement("td"); 
			var ftd2= document.createElement("td");
			ftd1.setAttribute("colspan","4");
			ftd1.innerHTML=item.comments;
			
			var but=document.createElement("button");
			but.innerHTML="投诉进度";
			ftd2.appendChild(but);
			tr3.appendChild(ftd1);
			tr3.appendChild(ftd2);
			tbody.appendChild(tr3);}
			tb.appendChild(thead);
			tb.appendChild(tbody);
			}
		});
	};
</script>
</html>